import { resolve } from 'path'
import { defineConfig } from 'vite'
import { createVitePlugin, createViteProxy } from './vite.helper'

export const pathResolve = (dir: string) => {
  return resolve(process.cwd(), './', dir)
}

// https://vitejs.dev/config/
export default defineConfig({
  base: '/power-screen/',
  plugins: createVitePlugin(),
  resolve: {
    alias: [
      {
        find: '@',
        replacement: pathResolve('src') + '/'
      }
    ],
    // 忽略后缀名的配置选项, 添加 .vue 选项时要记得原本默认忽略的选项也要手动写入
    extensions: ['.ts', '.js', '.vue', '.jsx', '.tsx', '.mjs', '.json']
  },
  server: {
    host: true,
    https: false,
    port: 9000,
    proxy: createViteProxy()
  }
})
